import 'package:flutter/material.dart';

class ButtonDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Button 部件"),
        centerTitle: true,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                PopupMenuButtonDemo(),
              ],
            )
          ],
        ),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      //   floatingActionButton: FloatingActionButtonDemo(),
      //   bottomNavigationBar: BottomAppBarDemo(),
    );
  }
}

// FloatingActionButton() 浮动按钮
class FloatingActionButtonDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FloatingActionButton(
      child: Icon(Icons.add),
      onPressed: () {},
      backgroundColor: Colors.black,
      //   shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
    );
  }
}

// FloatingActionButton() 浮动按钮
class FloatingActionButtonExtendedDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FloatingActionButton.extended(
      icon: Icon(Icons.add),
      label: Text("新增"),
      onPressed: () {},
      //   backgroundColor: Colors.black,
      //   shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
    );
  }
}

// BottomAppBar() 底部导航栏
class BottomAppBarDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BottomAppBar(
      child: Container(
        height: 80.0,
      ),
      elevation: 10.0,
      color: Colors.grey,
      shape: CircularNotchedRectangle(),
    );
  }
}

//  FloatButton() 文字按钮
class FlatButtonDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FlatButton(
      onPressed: () {},
      child: Text("文字按钮"),
      textColor: Colors.red,
    );
  }
}

// Expanded() 占满所有可用的空间
class ExpandedDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: RaisedButton.icon(
        icon: Icon(Icons.add),
        label: Text("新增"),
        onPressed: () {},
      ),
    );
  }
}

// PopupMenuButton() 弹出菜单按钮
class PopupMenuButtonDemo extends StatelessWidget {
  void _selectThis(String value) {
    print(value);
  }

  @override
  Widget build(BuildContext context) {
    return PopupMenuButton(
      onSelected: _selectThis,
      itemBuilder: (BuildContext context) => [
        PopupMenuItem(
          child: Text("Hemo"),
          value: 'Hemo',
        ),
        PopupMenuItem(
          child: Text("Case"),
          value: 'Case',
        ),
        PopupMenuItem(
          child: Text("About"),
          value: 'About',
        ),
      ],
    );
  }
}
